package com.hc.fdkgoods.dao;

import com.hc.fdkgoods.vo.ForwarderSummaryVO;
import org.springframework.stereotype.Repository;

import java.util.List;

import static com.hc.fdkgoods.db.tables.SellerOnPrepareSkuList.SELLER_ON_PREPARE_SKU_LIST;
import static org.jooq.impl.DSL.*;

@Repository
public class SellerOnPrepareSkuListDao extends BaseDao{
    public ForwarderSummaryVO getForwarderPushed(){
        // 已推送sku
        ForwarderSummaryVO forwarderSummaryVO = new ForwarderSummaryVO();
        long skuCount = db.select(
                countDistinct(SELLER_ON_PREPARE_SKU_LIST.SELLER_SKU_ID))
                .from(SELLER_ON_PREPARE_SKU_LIST)
                .fetchAnyInto(Long.class);
        long skuSum = db.select(
                sum(SELLER_ON_PREPARE_SKU_LIST.PREPARE_NUM))
                .from(SELLER_ON_PREPARE_SKU_LIST)
                .fetchAnyInto(Long.class);
        forwarderSummaryVO.setSkuCount(skuCount);
        forwarderSummaryVO.setSkuSum(skuSum);
        return forwarderSummaryVO;
    }
}
